import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AttendanceStatsVO, AttendanceStatsForm, AttendanceStatsQuery } from '@/api/dormitory/attendanceStats/types';

/**
 * 查询宿舍考勤统计列表
 * @param query
 * @returns {*}
 */

export const listAttendanceStats = (query?: AttendanceStatsQuery): AxiosPromise<AttendanceStatsVO[]> => {
  return request({
    url: '/dormitory/attendanceStats/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询宿舍考勤统计详细
 * @param id
 */
export const getAttendanceStats = (id: string | number): AxiosPromise<AttendanceStatsVO> => {
  return request({
    url: '/dormitory/attendanceStats/' + id,
    method: 'get'
  });
};

/**
 * 新增宿舍考勤统计
 * @param data
 */
export const addAttendanceStats = (data: AttendanceStatsForm) => {
  return request({
    url: '/dormitory/attendanceStats',
    method: 'post',
    data: data
  });
};

/**
 * 修改宿舍考勤统计
 * @param data
 */
export const updateAttendanceStats = (data: AttendanceStatsForm) => {
  return request({
    url: '/dormitory/attendanceStats',
    method: 'put',
    data: data
  });
};

/**
 * 删除宿舍考勤统计
 * @param id
 */
export const delAttendanceStats = (id: string | number | Array<string | number>) => {
  return request({
    url: '/dormitory/attendanceStats/' + id,
    method: 'delete'
  });
};
